<?php
namespace app\circle\validate;

use think\Validate;

/**
 * 验证
 */
class Comment extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'circle_id'     => 'require|integer',
        'comment_id'    => 'requireWith:reply_user_id',
        'reply_user_id' => 'requireWith:comment_id',
        'content'       => 'requireWithout:attach',
        'attach'        => 'requireWithout:content|/^[\d,]+$/',
        'id'            => 'require|number',
    ];

    protected $field = [
        'circle_id'     => '圈子',
        'comment_id'    => '被回复评论',
        'reply_user_id' => '被回复用户',
        'content'       => '内容',
        'attach'        => '附件',
        'id'            => '评论',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create'    => ['circle_id', 'comment_id', 'reply_user_id', 'content', 'attach'],
        'delete'    => ['id'],
    ];

}
